package com.example.glgk.controller.gather;

import com.example.glgk.dto.QueryEscalation;
import com.example.glgk.dto.gather.DeptEscalationDataDto;
import com.example.glgk.service.gather.DataGatherService;
import com.example.glgk.service.gather.DeptGatherService;
import com.example.glgk.utils.R;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author lxk
 * <p>部门指标查询接口</p>
 */
@Api(tags = "职能部门指标查询接口")
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/DeptGatherController")
public class DeptGatherController {

    @Autowired
    DeptGatherService deptGatherService;

    @ApiOperation(value = "部门指标查询")
    @PostMapping("/queryDeptData")
    public List<DeptEscalationDataDto> queryDeptData(@RequestBody QueryEscalation queryEscalation){
        return deptGatherService.queryDeptData(queryEscalation);
    }

    @ApiOperation(value = "指标汇总查询导出Excel")
    @PostMapping("/export")
    public void export(@RequestBody QueryEscalation queryEscalation, HttpServletResponse response){
        deptGatherService.export(queryEscalation,response);
    }


    @ApiOperation(value = "数据查询-职能部门指标查询、院领导汇总查询")
    @PostMapping("/queryDeptIndicatorData")
    public R queryDeptIndicatorData(@RequestBody QueryEscalation queryEscalation){
        return R.ok().put("page",deptGatherService.queryDeptIndicatorData(queryEscalation));
    }

    @ApiOperation(value = "职能部门指标查询导出Excel")
    @PostMapping("/exportDeptData")
    public void exportDeptData(@RequestBody QueryEscalation queryEscalation, HttpServletResponse response){
        deptGatherService.exportDeptData(queryEscalation,response);
    }

}
